from dvadmin.utils.models import BaseModel
from django.db.models import CharField
from django.db.models import TextField
from django.db.models import IntegerField
from django.db.models import FloatField
from django.db.models import BigIntegerField
from django.db.models import DateField

from pdms.state import COMP_TYPE_CHOICES
from pdms.state import COMP_BUS_TYPE_CHOICES
from pdms.state import COMP_INS_TYPE_CHOICES
from pdms.state import COMP_PRO_TYPE_CHOICES
from pdms.state import COMP_RANK_TYPE_CHOICES


class compModel(BaseModel):
    # 公司名称
    name = CharField(max_length=255, verbose_name='公司名称', help_text="公司名称")
    owner = CharField(max_length=125, verbose_name='公司法人', help_text="公司法人", blank=True, null=True)
    url = CharField(max_length=125, verbose_name='公司网址', help_text="公司网址", blank=True, null=True)
    cap = IntegerField(verbose_name='实缴资本【万】', help_text="实缴资本【万】", default=0, blank=True)
    val = IntegerField(verbose_name='市值【亿】', help_text="市值【亿】", default=0, blank=True)
    empNum = IntegerField(verbose_name='参保人数', help_text="参保人数", default=0, blank=True)
    province = CharField(max_length=32, verbose_name='省份', help_text="省份", blank=True, null=True)
    city = CharField(max_length=32, verbose_name='地市', help_text="地市", blank=True, null=True)
    district = CharField(max_length=32, verbose_name='区县', help_text="区县'", blank=True, null=True)
    street = CharField(max_length=32, verbose_name='街道/乡镇', help_text="街道/乡镇", blank=True, null=True)
    address = CharField(max_length=32, verbose_name='详细地址', help_text="详细地址", blank=True, null=True)
    type = IntegerField(
        choices=COMP_TYPE_CHOICES, default=0, verbose_name="公司类型", help_text="公司类型", null=True, blank=True,
    )
    busType = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, default=0, verbose_name="业务分类", help_text="业务分类", null=True, blank=True,
    )
    insType = IntegerField(
        choices=COMP_INS_TYPE_CHOICES, default=0, verbose_name="行业分类", help_text="行业分类", null=True, blank=True,
    )
    scope = TextField(verbose_name='经营范围', help_text="经营范围", blank=True, null=True)

    progress = IntegerField(
        choices=COMP_PRO_TYPE_CHOICES, default=0, verbose_name="合作进度", help_text="合作进度", null=True, blank=True,
    )
    rank = IntegerField(
        choices=COMP_RANK_TYPE_CHOICES, default=0, verbose_name="客户优先级", help_text="客户优先级", null=True, blank=True,
    )
    collaborator = CharField(max_length=32, verbose_name='合作人员', help_text="合作人员", blank=True, null=True)

    class Meta:
        db_table = "pdms_comp"
        verbose_name_plural = "客户表"
        ordering = ("empNum",)


class pumpModel(BaseModel):
    type = CharField(max_length=255, verbose_name='型号')
    flow = CharField(max_length=255, verbose_name='流量')
    height = CharField(max_length=255, verbose_name='扬程')
    power = FloatField(verbose_name='功率')
    rev = IntegerField(verbose_name='转速', blank=True, null=True)
    calibre = IntegerField(verbose_name='口径', blank=True, null=True)
    compType = CharField(max_length=32, verbose_name='所属公司类型')
    kind = CharField(max_length=32, verbose_name='水泵类型')
    url1 = CharField(max_length=255, verbose_name='安装图纸', blank=True, null=True)
    url2 = CharField(max_length=255, verbose_name='性能图纸', blank=True, null=True)
    url3 = CharField(max_length=255, verbose_name='安装图纸2', blank=True, null=True)
    url4 = CharField(max_length=255, verbose_name='性能图纸2', blank=True, null=True)

    class Meta:
        db_table = "pdms_pump"
        verbose_name_plural = '水泵型号信息表'


class projectModel(BaseModel):
    comp_id = BigIntegerField(verbose_name='客户ID', help_text="客户ID")
    date = DateField(verbose_name='登录时间', help_text="登录时间")
    comp_name = CharField(max_length=64, verbose_name='公司名称', help_text="公司名称")
    projectName = CharField(max_length=128, verbose_name='项目名称', help_text="项目名称")
    address = CharField(max_length=255, verbose_name='详细地址', help_text="详细地址", blank=True, null=True)
    invest = IntegerField(verbose_name='投资额【亿】', help_text="投资额【亿】", default=0, blank=True)
    desc = TextField(verbose_name='项目描述', help_text="项目描述", blank=True, null=True)

    compName1 = CharField(max_length=64, verbose_name='公司名称1', help_text="公司名称1", null=True, blank=True)
    compName2 = CharField(max_length=64, verbose_name='公司名称2', help_text="公司名称2", null=True, blank=True)
    compName3 = CharField(max_length=64, verbose_name='公司名称3', help_text="公司名称3", null=True, blank=True)
    compName4 = CharField(max_length=244, verbose_name='公司名称4', help_text="公司名称4", null=True, blank=True)
    compName5 = CharField(max_length=64, verbose_name='公司名称5', help_text="公司名称5", null=True, blank=True)
    compName6 = CharField(max_length=64, verbose_name='公司名称6', help_text="公司名称6", null=True, blank=True)
    compName7 = CharField(max_length=64, verbose_name='公司名称7', help_text="公司名称7", null=True, blank=True)
    compName8 = CharField(max_length=64, verbose_name='公司名称8', help_text="公司名称8", null=True, blank=True)

    dept1 = CharField(max_length=128, verbose_name='部门-职位-姓名 1', help_text="部门-职位-姓名1", null=True, blank=True)
    dept2 = CharField(max_length=128, verbose_name='部门-职位-姓名 2', help_text="部门-职位-姓名2", null=True, blank=True)
    dept3 = CharField(max_length=128, verbose_name='部门-职位-姓名 3', help_text="部门-职位-姓名3", null=True, blank=True)
    dept4 = CharField(max_length=244, verbose_name='部门-职位-姓名 4', help_text="部门-职位-姓名4", null=True, blank=True)
    dept5 = CharField(max_length=128, verbose_name='部门-职位-姓名 5', help_text="部门-职位-姓名5", null=True, blank=True)
    dept6 = CharField(max_length=128, verbose_name='部门-职位-姓名 6', help_text="部门-职位-姓名6", null=True, blank=True)
    dept7 = CharField(max_length=128, verbose_name='部门-职位-姓名 7', help_text="部门-职位-姓名7", null=True, blank=True)
    dept8 = CharField(max_length=128, verbose_name='部门-职位-姓名 8', help_text="部门-职位-姓名8", null=True, blank=True)

    phone1 = CharField(max_length=32, verbose_name='电话1', help_text="电话1", null=True, blank=True)
    phone2 = CharField(max_length=32, verbose_name='电话2', help_text="电话2", null=True, blank=True)
    phone3 = CharField(max_length=32, verbose_name='电话3', help_text="电话3", null=True, blank=True)
    phone4 = CharField(max_length=32, verbose_name='电话4', help_text="电话4", null=True, blank=True)
    phone5 = CharField(max_length=32, verbose_name='电话5', help_text="电话5", null=True, blank=True)
    phone6 = CharField(max_length=32, verbose_name='电话6', help_text="电话6", null=True, blank=True)
    phone7 = CharField(max_length=32, verbose_name='电话7', help_text="电话7", null=True, blank=True)
    phone8 = CharField(max_length=32, verbose_name='电话8', help_text="电话8", null=True, blank=True)
    cusType1 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类1", help_text="业务分类1", null=True, blank=True,
    )
    cusType2 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类2", help_text="业务分类2", null=True, blank=True,
    )
    cusType3 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类3", help_text="业务分类3", null=True, blank=True,
    )
    cusType4 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类4", help_text="业务分类4", null=True, blank=True,
    )
    cusType5 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类5", help_text="业务分类5", null=True, blank=True,
    )
    cusType6 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类6", help_text="业务分类6", null=True, blank=True,
    )
    cusType7 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类7", help_text="业务分类7", null=True, blank=True,
    )
    cusType8 = IntegerField(
        choices=COMP_BUS_TYPE_CHOICES, verbose_name="业务分类8", help_text="业务分类8", null=True, blank=True,
    )
    progressDesc = TextField(verbose_name='跟踪进度', help_text="跟踪进度", blank=True, null=True)

    class Meta:
        db_table = "pdms_project"
        verbose_name_plural = '项目信息表'
